<?php
class PNSpaRoom extends PNObject {
  function PNSpaRoom($init=null, $where='')
  {
    $this->PNObject();

    $this->_objType       = 'spaservice_sparoom';
    $this->_objField      = 'id';
    $this->_objPath       = 'form';

    $this->_init($init, $where);
  }
  
  function getDataFromInputJSON()
  {
      $stdClass = json_decode(file_get_contents('php://input'));
      
      foreach($stdClass AS $key=>$val){
        $obj[$key] = $val;
      }
      if ($obj) {
          $this->_objData = $obj;
          $this->getDataFromInputPostProcess();
          return $this->_objData;
      }

      return $default;
  }
  
   function insertPostProcess()
  {
    $form = FormUtil::getPassedValue('form',FALSE);
    
    $spaCategory_spaRoomTable = 'spaservice_spacategory_sparoom';
       
          
    foreach($form['category'] AS $value){
      $object[]  = array(
                'spaCategory_id' => $value,
                'spaRoom_id' => $this->_objData['id']
          );
    }
    
    //Do the insert
    DBUtil::insertObjectArray($object, $spaCategory_spaRoomTable);
  }
}